package com.pureut.system.controller;

import java.util.Arrays;
import java.util.List;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;

import com.pureut.system.domain.vo.SupplierAccessVo;
import com.pureut.system.domain.vo.SupplierEliminationVo;
import com.pureut.system.service.ISupplierEliminationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



/**
 * @Author: pureut
 * @Date: 2024-12-05 17:16:19
 * @Desc: 供应商淘汰Controller
 */
@RestController
@RequestMapping("/supplierElimination")
public class SupplierEliminationController extends BaseController {

    /**
     * 供应商淘汰Service
     */
    @Autowired
    private ISupplierEliminationService supplierEliminationService;

    /**
     * 查询供应商淘汰列表
     * @param: params 参数列表
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("supplierElimination-list")
    @GetMapping("/list")
    public TableDataInfo list(SupplierEliminationVo supplierEliminationVo) {
        startPage();

        return getDataTable(supplierEliminationService.queryPage(supplierEliminationVo));
    }


    /**
     * 获取供应商淘汰详细信息
     * @param: id 供应商淘汰主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("supplierElimination-query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(supplierEliminationService.getById(id));
    }

    /**
     * 新增供应商淘汰
     * @param: supplierElimination 供应商淘汰对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("supplierElimination-add")
    @PostMapping
    public AjaxResult add( @RequestBody SupplierEliminationVo supplierEliminationVo) {
        return toAjax(supplierEliminationService.save(supplierEliminationVo));
    }

    /**
     * 修改供应商淘汰
     * @param: supplierElimination 供应商淘汰对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("supplierElimination-edit")
    @PutMapping
    public AjaxResult edit( @RequestBody SupplierEliminationVo supplierEliminationVo) {
        return toAjax(supplierEliminationService.updateById(supplierEliminationVo));
    }

    /**
     * 删除供应商淘汰
     * @param: id 供应商淘汰主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("supplierElimination-remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(supplierEliminationService.removeByIds(Arrays.asList(ids)));
    }

    /**
     * 提交
     * @param: supplierAccess 供应商准入对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("supplierAccess-edit")
    @PutMapping("/submit/{id}")
    public AjaxResult submit(@PathVariable Long id ) {
        return toAjax(supplierEliminationService.submit(id));
    }

    /**
     * 审核
     * @param: supplierAccess 供应商准入对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("supplierAccess-edit")
    @PutMapping("/examine")
    public AjaxResult examine(@RequestBody SupplierEliminationVo supplierEliminationVo) {
        return toAjax(supplierEliminationService.examine(supplierEliminationVo));
    }
}
